# Carnal Realms common morality and utility triggers.

lustful_religion = {
	custom_tooltip = {
		text = lustful_religion_tooltip
		hidden_trigger = {
			always = yes
		}
	}
}

equality_religion = {
	custom_tooltip = {
		text = equality_religion_tooltip
		hidden_trigger = {
			OR = {
				religion = catholic
				# religion = cathar # CR DISABLED: removed from the CR religion roster
				religion = messalian
				religion = mazdaki
				has_religion_feature = religion_equal
				has_religion_feature = religion_feature_bon
			}
		}
	}
}

equality_culture = {
	custom_tooltip = {
		text = equality_culture_tooltip
		hidden_trigger = {
			OR = {
				culture = basque
				culture = zhangzhung
				culture = sumpa
			}
		}
	}
}

incest_religion = {
	custom_tooltip = {
		text = incest_religion_tooltip
		hidden_trigger = {
			OR = {
				religion = catholic
				religion = messalian
				religion_group = zoroastrian_group
				has_religion_feature = religion_holy_family
				has_religion_feature = religion_feature_zun
				has_religion_feature = religion_incest
			}
		}
	}
}

priestess_whore_religion = {
	custom_tooltip = {
		text = priestess_whore_religion_tooltip
		hidden_trigger = {
			OR = {
				religion = catholic
				has_religion_feature = religion_priestess_whore
			}
		}
	}
}

adultery_divorce_allowed = {
	custom_tooltip = {
		text = adultery_divorce_allowed_tooltip
		hidden_trigger = {
			religion_group = jewish_group
		}
	}
}

# Character-scope morality gates used by the CR adultery and bastard chains.
cr_adultery_celebrated_religion_trigger = {
	NOT = { religion_group = jewish_group }
}

cr_adultery_condemned_religion_trigger = {
	religion_group = jewish_group
}

cr_available_adult_character_trigger = {
	is_adult = yes
	prisoner = no
	is_incapable = no
	is_inaccessible_trigger = no
}

# Character scope. CR religions use one of three active consort limits.
cr_can_take_another_consort_trigger = {
	has_concubinage = yes
	OR = {
		AND = {
			OR = {
				religion = yazidi
				religion = druze
			}
			num_of_consorts < 4
		}
		AND = {
			religion = pagan
			num_of_consorts < 3
		}
		AND = {
			NOR = {
				religion = yazidi
				religion = druze
				religion = pagan
			}
			num_of_consorts < 12
		}
	}
}

# Target scope. ROOT is the adult character considering intimacy.
cr_valid_intimacy_partner_trigger = {
	cr_available_adult_character_trigger = yes
	NOT = { character = ROOT }
	ROOT = { is_adult = yes }
	OR = {
		AND = {
			same_sex = ROOT
			trait = homosexual
			ROOT = { trait = homosexual }
		}
		AND = {
			NOT = { same_sex = ROOT }
			NOT = { trait = homosexual }
			ROOT = { NOT = { trait = homosexual } }
		}
	}
}

# Target scope. Spouses are deliberately excluded so this remains a blood-kin
# option; Jewish law bars the option for either participant.
cr_valid_relative_intimacy_partner_trigger = {
	cr_valid_intimacy_partner_trigger = yes
	is_close_relative = ROOT
	NOT = { is_married = ROOT }
	NOT = { religion_group = jewish_group }
	ROOT = { NOT = { religion_group = jewish_group } }
}

cr_has_prostitution_career_trait = {
	OR = {
		trait = cheap_whore
		trait = experienced_whore
		trait = exclusive_whore
	}
}

cr_has_carnal_calling_trait = {
	OR = {
		trait = lustful
		trait = nymphomaniac
		trait = exhibitionist
		trait = hedonist
		trait = seducer
		trait = seductress
		trait = cheap_whore
		trait = experienced_whore
		trait = exclusive_whore
	}
}

cr_has_lovers_pox_trigger = {
	OR = {
		trait = lovers_pox
		has_character_modifier = minor_disease_herpes
	}
}

cr_holding_has_brothel_trigger = {
	OR = {
		has_building = ca_cr_brothel
		has_building = ct_cr_brothel
		has_building = tb_cr_brothel
	}
}

cr_has_brothel_access_trigger = {
	# Character-scope helper for future prostitution decisions and events.
	OR = {
		location = {
			any_province_holding = {
				cr_holding_has_brothel_trigger = yes
			}
		}
		capital_scope = {
			any_province_holding = {
				cr_holding_has_brothel_trigger = yes
			}
		}
		any_demesne_province = {
			any_province_holding = {
				cr_holding_has_brothel_trigger = yes
			}
		}
	}
}

cr_valid_brothel_worker_trigger = {
	cr_available_adult_character_trigger = yes
	NOT = { trait = chaste }
	NOT = { trait = celibate }
	NOT = { has_character_flag = cr_brothel_shift_in_progress }
}

cr_can_take_brothel_shift_trigger = {
	cr_valid_brothel_worker_trigger = yes
	cr_has_brothel_access_trigger = yes
	NOT = { has_character_modifier = cr_brothel_shift_cooldown }
}

cr_valid_brothel_client_trigger = {
	cr_available_adult_character_trigger = yes
	is_female = no
	NOT = { trait = eunuch }
	wealth = 5
}

cr_valid_group_brothel_client_trigger = {
	cr_valid_brothel_client_trigger = yes
	NOT = { has_character_flag = cr_brothel_group_client_selected }
}

cr_has_breast_size_trait = {
	cr_has_bosom_size_trait = yes
}

cr_has_bosom_size_trait = {
	OR = {
		trait = cr_small_bosom
		trait = cr_moderate_bosom
		trait = cr_full_bosom
		trait = cr_ample_bosom
		trait = cr_very_large_bosom
	}
}

cr_can_have_visible_bosom_size_trait = {
	OR = {
		is_female = yes
		trait = cr_hermaphrodite
	}
}

cr_needs_breast_size_trait = {
	cr_can_have_visible_bosom_size_trait = yes
	OR = {
		NOT = { has_character_flag = cr_breast_size_set }
		NOT = { cr_has_bosom_size_trait = yes }
	}
}

cr_has_invalid_visible_bosom_size_trait = {
	cr_has_bosom_size_trait = yes
	NOT = { cr_can_have_visible_bosom_size_trait = yes }
}

cr_has_dick_size_trait = {
	OR = {
		trait = cr_small_dick
		trait = cr_average_dick
		trait = cr_large_dick
		trait = cr_exceptional_dick
	}
}

cr_can_have_visible_dick_size_trait = {
	OR = {
		is_female = no
		trait = cr_hermaphrodite
	}
}

cr_needs_dick_size_trait = {
	cr_can_have_visible_dick_size_trait = yes
	OR = {
		NOT = { has_character_flag = cr_dick_size_set }
		NOT = { cr_has_dick_size_trait = yes }
	}
}

cr_has_invalid_visible_dick_size_trait = {
	cr_has_dick_size_trait = yes
	NOT = { cr_can_have_visible_dick_size_trait = yes }
}

cr_has_bosom_preference_flag = {
	OR = {
		has_character_flag = cr_body_prefers_small_bosom
		has_character_flag = cr_body_prefers_moderate_bosom
		has_character_flag = cr_body_prefers_full_bosom
		has_character_flag = cr_body_prefers_ample_bosom
		has_character_flag = cr_body_prefers_very_large_bosom
	}
}

cr_has_dick_preference_flag = {
	OR = {
		has_character_flag = cr_body_prefers_small_dick
		has_character_flag = cr_body_prefers_average_dick
		has_character_flag = cr_body_prefers_large_dick
		has_character_flag = cr_body_prefers_exceptional_dick
	}
}

# Target-scope check. ROOT is the adult observer whose opinion is being built.
cr_body_preference_matches_root_orientation_trigger = {
	is_adult = yes
	ROOT = { is_adult = yes }
	OR = {
		AND = {
			is_female = yes
			ROOT = {
				is_female = no
				NOT = { trait = homosexual }
			}
		}
		AND = {
			is_female = no
			ROOT = {
				is_female = yes
				NOT = { trait = homosexual }
			}
		}
		AND = {
			is_female = yes
			ROOT = {
				is_female = yes
				trait = homosexual
			}
		}
		AND = {
			is_female = no
			ROOT = {
				is_female = no
				trait = homosexual
			}
		}
	}
}

cr_realm_has_any_female_authority_trigger = {
	# Character-scope helper for later module events and decisions.
	OR = {
		has_law = cr_female_authority_law_1
		has_law = cr_female_authority_law_2
		has_law = cr_female_authority_law_3
		has_law = cr_female_authority_law_4
		top_liege = { has_law = cr_female_authority_law_1 }
		top_liege = { has_law = cr_female_authority_law_2 }
		top_liege = { has_law = cr_female_authority_law_3 }
		top_liege = { has_law = cr_female_authority_law_4 }
	}
}

cr_realm_has_equal_female_authority_trigger = {
	# Character-scope helper for legal equality or stronger.
	OR = {
		has_law = cr_female_authority_law_2
		has_law = cr_female_authority_law_3
		has_law = cr_female_authority_law_4
		top_liege = { has_law = cr_female_authority_law_2 }
		top_liege = { has_law = cr_female_authority_law_3 }
		top_liege = { has_law = cr_female_authority_law_4 }
	}
}

cr_realm_has_matriarchal_authority_trigger = {
	# Character-scope helper for female-preference authority or stronger.
	OR = {
		has_law = cr_female_authority_law_3
		has_law = cr_female_authority_law_4
		top_liege = { has_law = cr_female_authority_law_3 }
		top_liege = { has_law = cr_female_authority_law_4 }
	}
}

cr_realm_has_supreme_female_authority_trigger = {
	# Character-scope helper for the fully matriarchal law tier.
	OR = {
		has_law = cr_female_authority_law_4
		top_liege = { has_law = cr_female_authority_law_4 }
	}
}
